package operations;

import agent.State;

public class SailLeft implements Operation{

	@Override
	public State exec(State nod) {
		if (!validOperation(nod))
			return null;
		State ret = nod.dupe();
		ret.setBoatLeft(true);
		ret.setBoatRight(false);
		return ret;
	}

	@Override
	public boolean validOperation(State nod) {
		if (!nod.isBoatRight())
			return false;
		if ((nod.isCabadgeRight() && nod.isGoatRight()) ||
			(nod.isWolfRight() && nod.isGoatRight()))
			return false;
		return true;
	}

}
